<template>
    <view class="filemanager-list">
	 <scroll-view class="listview" style="flex: 1;" enableBackToTop="true" scroll-y @scrolltolower="loadData()">
        <view class="item" v-for="(item, index) in bizFileManagerData" :key="index" :index="index" @tap="moreTapItem(item, index)">
            <uni-row style="margin-bottom: 25rpx;">
                <uni-col :span="4">
                  <uni-icons type="flag" size="60" color="red"></uni-icons>
                </uni-col>
          <uni-col :span="20" style="text-align: left;line-height: 80rpx;">
              <view  class="name"> {{item.name}}</view>
          </uni-col>
            </uni-row>
			<uni-row>
				<uni-col :span="6" textAlign="right">
				    <view class="item-right snowy-bold snowy-ellipsis"> {{ item.fileType }} </view>
				</uni-col>
				<uni-col :span="15" textAlign="right">
				    <view class="item-right snowy-bold snowy-ellipsis"> {{ item.updateTime }} </view>
				</uni-col>
				
				<uni-col :span="2" textAlign="right">
				<uni-link :href="item.downloadPath" text="下载"></uni-link>
				</uni-col>
			</uni-row>
        </view>
	</scroll-view>
    </view>
    <!-- <snowy-empty :fixed="true" v-show="$xeu.isEmpty(bizFileManagerData)" /> -->
    <!-- <snowy-float-btn v-if="$snowy.hasPerm('mobileBizFileManagerAdd')" @click="add"></snowy-float-btn> -->
    <!-- <more ref="moreRef" @handleOk="loadData(true)"></more> -->
</template>

<script setup name="filemanager">
    import  bizFileManager  from '@/api/biz/biz-file-manager-api.js'
    // import more from './more.vue'
    import { onLoad, onShow, onReady, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app"
    import { reactive, ref, getCurrentInstance } from "vue"
    const { proxy } = getCurrentInstance()
    const searchFormState = reactive({
    })
    const parameter = reactive({
    	current: 1,
    	size: 10,
		searchKey:'公示管理文件'
    })
    const bizFileManagerData = ref([])
	
    const loadData = (isReset) => {
        if (isReset) {
        	parameter.current = 1
        	bizFileManagerData.value = []
        }
        Object.assign(parameter, searchFormState)
        bizFileManager.bizFileManagerPage(parameter).then(data => {
            if (uni.$xeu.isEmpty(data?.records)){
            	return
            }
			
            bizFileManagerData.value = bizFileManagerData.value.concat(data.records)
            parameter.current++
        }).finally(()=>{
          	uni.stopPullDownRefresh()
        })
    }
    loadData(true)
    onShow(() => {
    	uni.$once('formBack', (data) => {
            loadData(true)
    	})
    })
    // 下拉刷新
    onPullDownRefresh(() => {
    	loadData(true)
    })
    // 上拉加载
    onReachBottom(() => {
    	loadData()
    })
    // 新增
    const add = () => {
    	uni.navigateTo({
            url: '/pages/biz/filemanager/form'
    	})
    }
    // 更多操作
    const moreRef = ref()
    const moreTapItem = (item, index) => {
        moreRef.value.open(item)
    }
</script>

<style lang="scss" scoped>
    .filemanager-list {}
    .item {
        background: #ffffff;
        margin: 20rpx 0;
        padding: 25rpx;
        box-shadow: 0 1px 2px #ccc;
        border-radius: 15rpx;
        .item-left {
            color: #999;
            font-size: 26rpx;
        }
        .item-right {
            font-size: 26rpx;
        }
		.name{
			font-weight: bolder;
		}
    }
    .item:hover {
        box-shadow: 1upx 5upx 5upx #aaa;
    }
</style>
